package student;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class StudentUtil {
    static {
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
            }
    }

    public static Connection getConnection(){
        String url = "jdbc:mysql://localhost:3306/qus?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8";
        String username = "root";
        String password = "root";
        try {
            return DriverManager.getConnection(url,username,password);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    public static void main(String[] args) {
        Connection conn=StudentUtil.getConnection();
        System.out.println(conn);
    }
}
